package org.practice.chart;
/**
 * 静态工厂：创建相应的所需图表
 * @author jack
 */
public class FusionChartsFactory {
    //定义若干个重载方法，满足不同的需求
	public static FusionChart createColumnChart(){
        return new ColumnChart();
    }
	public static FusionChart createColumnChart(String caption,String...attr){
        return new ColumnChart(caption,attr);
    }
    public static FusionChart createColumnChart(ChartAttributeVO chartAttributeVO){
        ColumnChart columnChart=new ColumnChart(chartAttributeVO.getChartCaption());
        columnChart.setDataMap(chartAttributeVO.getDataMap());
        if(chartAttributeVO.getGraphProps()!=null){
            DataTransferUtil.changeChartProp(columnChart, chartAttributeVO.getGraphProps());
        }
        return columnChart;
    }


    public static FusionChart createPieChart(ChartAttributeVO chartAttributeVO){
        PieChart pieChart=new PieChart(chartAttributeVO.getChartCaption());
        pieChart.setDataMap(chartAttributeVO.getDataMap());
        return pieChart;
    }

    public static FusionChart createLineChart(ChartAttributeVO chartAttributeVO){
        LineChart lineChart=new LineChart(chartAttributeVO.getChartCaption());
        lineChart.setDataMap(chartAttributeVO.getDataMap());
        if(chartAttributeVO.getGraphProps()!=null){
            DataTransferUtil.changeChartProp(lineChart, chartAttributeVO.getGraphProps());
        }
        return lineChart;
    }

}
